import { reqCategoryListData, reqGetBannerListData, reqGetFloorListData } from "../../api"
export default {
    namespaced: true,
    state: {
        // 1. 存储 三级导航分类 数据
        categoryList: [],
        // 2.存储 轮播图 数据
        bannerList: [],
        //    3.存储 楼层数据
        floorList: []
    },

    mutations: {
        //1.设置state中 三级导航下拉列表的数据
        SetCategoryListData(state, categoryList) {
            state.categoryList = categoryList
        },
        // 2.设置 轮播图 的数据
        SetBannerListData(state, bannerList) {
            state.bannerList = bannerList
        },
        // 3.设置 楼层数据
        SetFloorListData(state, floorList) {
            state.floorList = floorList
        }
    },
    actions: {   //发送请求获取数据
        //1. 获取三级分类数据
        async getCategoryListData(context) {
            let { data, code } = await reqCategoryListData()
            if (code === 200) {
                context.commit("SetCategoryListData", data)
            } else {
                console.log(error.message)
            }

        },

        // 2.获取 轮播图 数据
        async getBannerListData({ commit }) {
            let { data, code } = await reqGetBannerListData()
            if (code === 200) {
                commit("SetBannerListData", data)
            } else {
                console.log(error.message)
            }
        },

        // 3.获取楼层数据
        async getFloorListData({ commit }) {
            let { data, code } = await reqGetFloorListData()
          
            if (code === 200) {
                commit("SetFloorListData", data)
            } else {
                console.log(error.message)
            }
        },
    },
    getters: {

    }
}